package com.qidian.mes.cal.controller;

import com.qidian.mes.cal.service.CalShiftService;
import com.qidian.mes.pojo.cal.CalPlan;
import com.qidian.mes.pojo.cal.CalShift;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 04冯虹丹
 * @Company 起点编程
 * @Time 2023/11/1 20:45
 * @Description
 */
@CrossOrigin
@RestController
@RequestMapping("/calShift")
public class CalShiftController {
    @Autowired
    private CalShiftService calShiftService;

    /**
     * 分页查询
     * @param page
     * @param limit
     * @param calShift
     * @return
     */
    @GetMapping("/list")
    public MESResult list(@RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10") int limit, CalShift calShift){
        return calShiftService.list(page,limit,calShift);
    }

    /**
     * 添加班次
     * @param calShift
     * @return
     */
    @PostMapping("/save")
    public MESResult save(@RequestBody CalShift calShift) {
        return calShiftService.save(calShift);
    }

    /**
     * 单个删除
     * @param shiftId
     * @return
     */
    @DeleteMapping("/{shiftId}")
    public MESResult delete(@PathVariable Long shiftId){
        return calShiftService.delete(shiftId);
    }

    /**
     * 批量删除
     * @param shiftId
     * @return
     */
    @DeleteMapping("/deletes")
    public MESResult deletes(Long [] shiftId){
        return calShiftService.deletes(shiftId);
    }

    /**
     * 根据班次Id查询
     * @param shiftId
     * @return
     */
    @GetMapping("/get")
    public MESResult get(Long shiftId){
        return calShiftService.get(shiftId);
    };

    /**
     * 编辑班次计划
     * @param calShift
     * @return
     */
    @PutMapping("/update")
    public MESResult update(@RequestBody CalShift calShift){
        return calShiftService.update(calShift);
    }
}
